<template>
  <div class="home">
    <Header>
      <div class="no-login" @click="goLogin"  v-if="!loginStatus">登录</div>
      <div class="login-tab" @click="goUser" v-else>
        <img src="../assets/image/my.svg" alt="" />
      </div>
      <template v-slot:header-search>
        <div class="header-search" @click="goSearch">
          <van-icon name="search" />
          <a href="./search" style="color: #fff">搜索</a>
        </div>
      </template>
    </Header>
    <Tab></Tab>
  </div>
</template>
<script>
import Header from "@/components/home/Header.vue";
import Tab from "@/components/home/Tab.vue";
import {mapState} from 'vuex'
export default {
  name: "Home",
  components: { Header, Tab },
  data() {
    return {
      username: "", //用户名
      password: "", //密码
      show: false, //是否显示弹层,默认不显示
    };
  },
  created() {
  },
  computed: {
    ...mapState({
      loginStatus: (state) => state.user.loginStatus,
      userInfo: (state) => state.user.userInfo,
    }),
  },
  methods: {
    goLogin() {
      this.$router.push({ path: "/login" });
    },
    goSearch() {
      this.$router.push({ path: "/search" });
    },
    goUser(){
      this.$router.push({path:'/user'})
    }
  },
};
</script>
<style scoped lang="less">
.home {
  .login-tab {
    border-radius: 50%;
    border: 1px solid #ededed;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    height: 20px;
    line-height: 20px;
    font-size: 20px;
    margin: 0 10px;
    padding: 5px;
    width: 20px;
    height: 20px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .no-login {
    color: #fff;
    padding: 10px 5px;
    font-size: 14px;
    margin-left: 10px;
  }
  .pop {
    .pop-userInfo {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-around;
      p {
        margin: 5px auto;
        font-size: 14px;
      }
    }
  }
  .header-search {
    display: flex;
    height: 35px;
    line-height: 35px;
    width: 66%;
    background-color: rgba(0, 0, 0, 0.1);
    font-size: 14px;
    border-radius: 15px;
    padding-left: 10px;
    .search-info {
      color: #fff;
    }
    .van-icon {
      color: #fff;
      top: 10px;
      margin-right: 10px;
    }
  }
}
</style>
